﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ShadowCommando.Utilites
{
    /// <summary>
    /// Klasa przedstawiająca punkty zdobyte przez gracza
    /// </summary>
    [Serializable]
    public class Score : IComparable
    {
        [XmlAttribute("Name")]
        private string name;
        [XmlAttribute("Points")]
        private int points;
        /// <summary>
        /// Konstruktor
        /// </summary>
        public Score()
        {
        }
       /// <summary>
       /// Konstruktor  
       /// </summary>
       /// <param name="_name"></param>
       /// <param name="_points"></param>
        public Score(string _name, int _points)
        {
            name = _name;
            points = _points;
        }
        /// <summary>
        /// Nazwa gracza
        /// </summary>
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }
        /// <summary>
        /// Punkty
        /// </summary>
        public int Points
        {
            get
            {
                return points;
            }
            set
            {
                points = value;
            }
        }
        /// <summary>
        /// Nazwa gracza i punkty
        /// </summary>
        /// <returns>Nazwa gracza i punkty</returns>
        public override string ToString()
        {
            return name + " " + points.ToString();
        }
        /// <summary>
        /// Impementacja interfejsu IComperable
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            Score score = obj as Score;
            if (points > score.points)
                return 1;
            else if (points < score.points)
                return -1;
            else
                return name.CompareTo(score.name);
        }
    }
}
